package com.test.webtest.controller;

import com.test.webtest.utils.IpAddressUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IpController {

    /**
     * 解析ip地址
     * @param ip
     * @return
     */
    @PostMapping("/parse")
    public String parseIp(@RequestParam String ip) {
        try {
            return IpAddressUtils.parseIpAddress(ip);
        } catch (Exception e) {
            return "地址解析失败";
        }
    }

}